<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2020/7/17
  Time: 14:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String basePath = request.getScheme()
            +"://"
            +request.getServerName()
            + ":"
            +request.getServerPort()
            +request.getContextPath()
            +"/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <title>登录</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/webjars/jquery/3.5.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
                //给验证码绑定单击事件
                $("#code_img").click(function () {
                    this.src = "kaptcha.jpg?d=" + new Date();
                });
                $("#sub_btn").click(function () {
                    var item = $(":radio:checked");
                    var len=item.length;
                    if(len>0){
                        if($(":radio:checked").val()==="judge"){
                            $("input:hidden").val("judgeLogin");
                        }
                    }else{
                      $("span.errorMsg").text("请选择用户类型！");
                        return false;
                    }
                    $("span.errorMsg").text("");
                });
        });
    </script>
</head>
<body>
<h1>用户登录</h1>
<a href="${pageContext.request.contextPath}/regist.jsp">立即注册</a>
<br>
<span class="errorMsg">
    ${requestScope.msg}
</span>
<div class="form">
    <form action="userServlet" method="post">
        <input type="hidden" name="action" id="action" value="login"/>
        <table>
            <tr>
                <td>用户名：</td>
                <td>
                    <input type="text" placeholder="请输入用户名" tabindex="1" name="username" id="username"
                           value="${requestScope.username}"/>
                </td>
            </tr>
            <tr>
                <td>用户密码：</td>
                <td>
                    <input type="password" placeholder="请输入密码" autocomplete="off" tabindex="1" name="password" id="password"/>
                </td>
            </tr>
            <tr>
                <td>用户类型:</td>
                <td>
                    <input type="radio" name="userType" id="systemUser" value="systemUser"/>系统用户
                    <input type="radio" name="userType" id="judge" value="judge"/>评委
                </td>
            </tr>
            <tr>
                <td>项目ID:</td>
                <td>
                    <input type="text" placeholder="(系统用户请忽略)" tabindex="1" name="projectId" id="projectId"/>
                </td>
            </tr>
            <tr>
            <td>验证码：</td>
            <td>
                <input type="text" tabindex="1" name="code" style="width:80px"><img id="code_img" src="kaptcha.jpg"  style="width:100px; height:28px">
            </td>
            </tr>
            <tr>
                <td>
            <tr>
                <td>
                    <input type="submit" value="登录" id="sub_btn"/>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>
